package main

import (
	"fmt"
	"sync/atomic"
)

func main4() {
	var (
		n uint64 = 97
		m uint64 = 1
		k int    = 2
	)
	const (
		a        = 3
		b uint64 = 4
		c uint32 = 5
		d int    = 6
	)
	show := fmt.Println
	atomic.AddUint64(&n, -m)
	show(n) // 96

	atomic.AddUint64(&n, -uint64(k)) // 96-2
	show(n)

	atomic.AddUint64(&n, ^uint64(a-1)) //94-3
	show(n)
}

func main5() {
	var n int64 = 123
	var old = atomic.SwapInt64(&n, 789)
	fmt.Println(n, old)
	swapped := atomic.CompareAndSwapInt64(&n, 123, 456)
	fmt.Println(swapped, n)
	swapped = atomic.CompareAndSwapInt64(&n, 789, 456)
	fmt.Println(swapped, n)
}
